from SimpleXMLRPCServer import SimpleXMLRPCServer
import xmlrpclib, os

var_path = '/Users/liushuai/temp/var'
f_name_list = os.listdir(var_path)

def getFileListStr():
	return '\n'.join(tuple(f_name_list))

def getFileList():
	return getFileListStr()

def getFile(index):
	f = open('/'.join((var_path, f_name_list[index])), 'rb')
	return xmlrpclib.Binary(f.read())
	f.close()

def getFileName(index):
	return f_name_list[index]
 
server = SimpleXMLRPCServer(("localhost", 8000), allow_none=True)

server.register_function(getFileList)
server.register_function(getFile)
server.register_function(getFileName)

print "Listening on port 8000..."
server.serve_forever()